Sistem Klas÷rlerini ╓≡renmekProgram²n²z²n kullanaca≡² geτici bir dosya olu■turmak istiyorsunuz. Ya da Windows'un bulundu≡u klas÷rⁿ program²n²za bildirmek istiyorsunuz. Bu i■lemleri gerτekle■tirmek τok basit τⁿnkⁿ Windows 3 adet API kullanarak bu klas÷rleri bulman²za izin veriyor. ╓rne≡imizi uygulamak iτin resimde g÷rⁿldⁿ≡ⁿ gibi ⁿτ adet etiket kontrolⁿ bir adet de komut butonunu formunuz ⁿzerine yerle■tirin.'Ayr² bir BAS modⁿlⁿne girecek: Option Explicit Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long Public Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _ (ByVal nSize As Long, ByVal lpBuffer As String) As Long Public Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long 'Formun General - Declarations b÷lⁿmⁿne girecek: Private Function GetSystemDir() As String Dim r As Long Dim nSize As Long Dim tmp As String tmp = Space$(256) nSize = Len(tmp) r = GetSystemDirectory(tmp, nSize) GetSystemDir = TrimNull(tmp) End Function Public Function GetTempDir() As String Dim r As Long Dim nSize As Long Dim tmp As String tmp = Space$(256) nSize = Len(tmp) r = GetTempPath(nSize, tmp) GetTempDir = TrimNull(tmp) End Function Private Function GetWinDir() As String Dim r As Long Dim nSize As Long Dim tmp As String tmp = Space$(256) nSize = Len(tmp) r = GetWindowsDirectory(tmp, nSize) GetWinDir = TrimNull(tmp) End Function Private Function TrimNull(item As String) Dim pos As Integer pos = InStr(item, Chr$(0)) If pos Then TrimNull = Left$(item, pos - 1) Else: TrimNull = item End If End Function Private Sub Command1_Click() Label1 = GetWinDir() Label2 = GetTempDir() Label3 = GetSystemDir() End Sub |